<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { pageVisitLog } from "@/api/log"
export default {
  name: 'App',
  metaInfo () {
    return {
      title: this.$store.state.settings.dynamicTitle && this.$store.state.settings.title,
      titleTemplate: title => {
        return title ? `${title} - ${process.env.VUE_APP_TITLE}` : process.env.VUE_APP_TITLE
      },
    }
  },
  data(){
    return{
      logParams:{
        systemId:3,
        environmentId:1,
        serviceId:13,
        url:""
      }
    }
  },
  created(){
    let site = process.env.VUE_APP_BASE_URL.split('/')[2]
    if(site == 'out.bj.51db.com:36101'){
      this.logParams.environmentId = 1
    }else if(site == 'out.bj.51db.com:36201'){
      this.logParams.environmentId = 2
    }else if(site == 'srm.b1b.cn:36301'){
      this.logParams.environmentId = 4
    }
    if(this.$route.path == '/' || this.$route.path == '/login'){
      this.logParams.url = this.$route.path;
      pageVisitLog(this.logParams).then(res=>{
        if(res.code == 200){
          return res
        }
      })
    }
    this.$router.beforeEach((to, from, next) => {
      this.logParams.url = to.path;
      pageVisitLog(this.logParams).then(res=>{
        if(res.code == 200){
          return res
        }
      })
      next();
    })
  },
  methods:{

  }
}
</script>